/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entities;

import interfaces.InternationalizableEntity;
import interfaces.InternationalizableEntityDescription;
import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author damfercer
 */
@Entity
@Table(name = "country_description")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "CountryDescription.findAll", query = "SELECT c FROM CountryDescription c"),
    @NamedQuery(name = "CountryDescription.findByIdCountryDescription", query = "SELECT c FROM CountryDescription c WHERE c.idCountryDescription = :idCountryDescription"),
    @NamedQuery(name = "CountryDescription.findByDescription", query = "SELECT c FROM CountryDescription c WHERE c.description = :description")})
public class CountryDescription implements Serializable, InternationalizableEntityDescription {
    private static final long serialVersionUID = 1L;
    @Id
    @GeneratedValue(strategy = GenerationType.IDENTITY)
    @Basic(optional = false)
    @Column(name = "ID_COUNTRY_DESCRIPTION")
    private Integer idCountryDescription;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 30)
    @Column(name = "DESCRIPTION")
    private String description;
    @JoinColumn(name = "ID_COUNTRY", referencedColumnName = "ID_COUNTRY")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Country idCountry;
    @JoinColumn(name = "ID_LANGUAGE", referencedColumnName = "ID_LANGUAGE")
    @ManyToOne(optional = false, fetch = FetchType.LAZY)
    private Language idLanguage;

    public CountryDescription() {
    }

    public CountryDescription(Integer idCountryDescription) {
        this.idCountryDescription = idCountryDescription;
    }

    public CountryDescription(Integer idCountryDescription, String description) {
        this.idCountryDescription = idCountryDescription;
        this.description = description;
    }

    public Integer getIdCountryDescription() {
        return idCountryDescription;
    }

    public void setIdCountryDescription(Integer idCountryDescription) {
        this.idCountryDescription = idCountryDescription;
    }

    @Override
    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Country getIdCountry() {
        return idCountry;
    }

    public void setIdCountry(Country idCountry) {
        this.idCountry = idCountry;
    }

    public Language getIdLanguage() {
        return idLanguage;
    }

    public void setIdLanguage(Language idLanguage) {
        this.idLanguage = idLanguage;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idCountryDescription != null ? idCountryDescription.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CountryDescription)) {
            return false;
        }
        CountryDescription other = (CountryDescription) object;
        if ((this.idCountryDescription == null && other.idCountryDescription != null) || (this.idCountryDescription != null && !this.idCountryDescription.equals(other.idCountryDescription))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entities.CountryDescription[ idCountryDescription=" + idCountryDescription + " ]";
    }

    @Override
    public InternationalizableEntity getEntity() {
        return getIdCountry();
    }
    
}
